import request from '@/utils/request'

// /admin/product/attrInfoList/{category1Id}/{category2Id}/{category3Id}
// attrInfoList

// DELETE /admin/product/deleteAttr/{attrId}
// deleteAttr

// GET /admin/product/getAttrValueList/{attrId}
// getAttrValueList

// POST /admin/product/saveAttrInfo

export interface AttrValueModel {
    id?: number,
    valueName: string,
    attrId?: number,
    inputVisible?: boolean
}

export interface AttrModel {
    id?: number,
    attrName: string,
    categoryId: number | undefined,
    categoryLevel: number,
    attrValueList: AttrValueModel[],
    // -----------------------------
    // 用来收集平台属性id和属性值id
    attrIdvalId?: string
}

export default {
    attrInfoList(category1Id: number, category2Id: number, category3Id: number) {
        return request.get<any, AttrModel[]>(`/admin/product/attrInfoList/${category1Id}/${category2Id}/${category3Id}`)
    },
    saveAttr(data: AttrModel) {
        return request.post<any, null>(`/admin/product/saveAttrInfo`, data)
    },
    deleteAttr(attrId: number) {
        return request.delete<any, null>(`/admin/product/deleteAttr/${attrId}`)
    }
}